/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "string.h"
#include "stdio.h"
#include <stdlib.h>
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */


extern uint8_t _1mstick;

typedef enum
{
    ORDER_NONE = 0,            
    ORDER_GET_DEV_INF_hex,          // hex;  +data(1byte)  1 ContinuousSend ; 0 disContinuousSend
    ORDER_GET_DEV_INF_ascii,        // ascii; +data(1byte) 1 ContinuousSend ; 0 disContinuousSend
    ORDER_GET_DEV_P_ascii,
    ORDER_GET_DEV_T_ascii,
    ORDER_GET_DEV_ADC,              // predata(2byte) + tempdata(2byte)
    ORDER_SET_DEV_ADDR,             //
    ORDER_GET_DEV_ADDR,             //
} CONTROL_MACHINE_E;

typedef struct 
{
    unsigned char DevAddr;
    CONTROL_MACHINE_E order;  // 
    unsigned char data[50]; // 
} controlinfo_S;
extern controlinfo_S  UartRecData;

typedef struct 
{
    unsigned int adc; 
    unsigned int val;
    unsigned int offset; 
    unsigned int factor;
} INFO_S;

typedef struct 
{
    INFO_S Pressure;        //   1234.56 mbar; offset = 0;factor = 100 ; val = 123456 = (1234.56 + offset)*factor  
    INFO_S Temperature;     //   25.1 ;  offset = 40;factor = 10 ; val =  651 = (25.1 + offset)*factor       
} SENSORINFO_S;
extern SENSORINFO_S  SensorInfo;
/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */
void fun_UsartSend(void);
void fun_DACtest(void);
void fun_LED(void);
int Flash_write(uint32_t appxaddr,uint32_t *appbuf,uint32_t appsize);
int Internal_ErasePage(uint32_t pageAddress, uint32_t nbPages);
uint32_t Flash_Read(uint32_t address);
void fun_flash_test(void);
/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define NTC_Pin GPIO_PIN_7
#define NTC_GPIO_Port GPIOA
#define LED_Pin GPIO_PIN_8
#define LED_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */

 //#define FLASH_PAGE_SIZE         ((uint32_t)0x00000400)   /* FLASH Page Size */
 #define FLASH_USER_START_ADDR   ((uint32_t)0x08006000)   /* Start @ of user Flash area */
 #define FLASH_USER_END_ADDR     ((uint32_t)0x08007000)   /* End @ of user Flash area */

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
